// 实现一个工具函数，接收一个callback风格的函数作为参数，返回一个对等的Promise风格的函数；

const rhyam = [
  {
    start: 12341824,
    end: 3122194,
  },
  {
    start: 12341824,
    end: 3122194,
  },
  {
    start: 12341824,
    end: 3122194,
  },
];

class MyPromise {

  constructor (onInit) {
    onInit(MyPromise.resolve, MyPromise.reject);
  }

  static resolve (res) {

  }

  static reject (err) {

  }

  static all (promiseList) {

  }

  static race (promiseList) {

  }

  then (onSuccess, onFail) {
    onSuccess(res);
  }

  catch (onError) {

  }

  finally (onFinally) {

  }

}

function _async (cb) {
  return new MyPromise((resolve, reject) => {

  });
}

async function fn () {

}

_async(function fn () {

});

function sleep (timeout) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(123);
    }, timeout);
  });
}

// const res = await sleep();
// res = 123

sleep().then((res) => {
  // res: 123
});
